package com.lxl.securitypermission.controller;

import com.lxl.securitypermission.constant.HttpCode;
import com.lxl.securitypermission.dto.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(value = "ErrorController",tags = "ErrorController")
@Slf4j
@Controller
public class ErrorController {

  @ApiOperation("未授权页面")
  @GetMapping("403")
  public String error403() {
    return "error/403";
  }

  @ApiOperation("404不存在URL页面")
  @GetMapping("404")
  @ResponseBody
  public Object error404(HttpServletRequest request) {
    log.warn("error404,远程地址-{} 异常信息-{}", request.getRemoteAddr(), "http404");
    //做些什么...
    return new ResponseResult<>(HttpCode.FAIL, "页面不存在！");
  }
}
